package lesson06;

import java.util.concurrent.TimeUnit;

public class Demo_602 {
    static int num1=1;
    public static void main(String[] args) {
        MyBlockingQueue myBlockingQueue=new MyBlockingQueue(100);
        Thread  thread1 =new Thread(()->{
            int num=0;
            while (true){
                try {
                    myBlockingQueue.put(num);
                    System.out.println("生产" + num);
                    num++;
                    TimeUnit.MILLISECONDS.sleep(10);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread1.start();

        Thread  thread2=new Thread(()->{

            while (true){
                int value=0;
                try {
                    value=myBlockingQueue.talk();
                    System.out.println("消费" + value);
                    TimeUnit.MILLISECONDS.sleep(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        thread2.start();
    }
}
